var util = require('../../utils/common.js'); //引入公共JS


Page({
  data: {
    showIcon: true,
    //显示返回键以及首页
    isFold1: false,
    //折叠 
    isFold2: false,
    //折叠 
    toView: '',
    fxFlag: true,
    //分享
    listFalg: true,
    //切换默认隐藏
    _list: '0',
    //切换
    tab_num: '0',
    //切换
    phoneNumber: "",
    //电话 
    days: "00",
    //天
    hours: "00",
    //时
    minutes: "00",
    //分
    seconds: "00",
    //秒
    timeFlag: false,
    //倒计时
    maskHidden: false
  },
  onLoad: function (options) {},
  onReady: function () {
    var time = util.timestamp("2022-7-10 17:33");
    var totalSecond = time - Date.parse(new Date()) / 1000;
    var interval = setInterval(function () {
      var second = totalSecond; // 秒数
      // 天数位

      var day = Math.floor(second / 3600 / 24);
      var dayStr = day.toString();
      if (dayStr.length == 1) dayStr = '0' + dayStr; // 小时位

      var hr = Math.floor((second - day * 3600 * 24) / 3600);
      var hrStr = hr.toString();
      if (hrStr.length == 1) hrStr = '0' + hrStr; // 分钟位

      var min = Math.floor((second - day * 3600 * 24 - hr * 3600) / 60);
      var minStr = min.toString();
      if (minStr.length == 1) minStr = '0' + minStr; // 秒位

      var sec = second - day * 3600 * 24 - hr * 3600 - min * 60;
      var secStr = sec.toString();
      if (secStr.length == 1) secStr = '0' + secStr;
      this.setData({
        days: dayStr,
        hours: hrStr,
        minutes: minStr,
        seconds: secStr
      });
      totalSecond--;

      if (totalSecond < 0) {
        clearInterval(interval);
        this.setData({
          timeFlag: true,
          days: '00',
          hours: '00',
          minutes: '00',
          seconds: '00'
        });
      }
    }.bind(this), 1000);
  },
  onPageScroll: function (e) {
    // 获取滚动条当前位置
    if (e.scrollTop > 100) {
      this.setData({
        floorstatus: true
      });
    } else {
      this.setData({
        floorstatus: false
      });
    }
  },
  goIndex: function () {
    //点击进入首页
    tt.switchTab({
      url: '../page/index/index'
    });
  },
  //回到顶部
  goTop: function () {
    util.goTop();
  },
  flodFn12: function () {
    this.setData({
      isFold2: false
    });
  },
  flodFn22: function () {
    this.setData({
      isFold2: true
    });
  },
  flodFn11: function () {
    this.setData({
      isFold1: false
    });
  },
  flodFn21: function () {
    this.setData({
      isFold1: true
    });
  },
  fxShow: function () {
    this.setData({
      fxFlag: false
    });
  },
  fxClose: function () {
    this.setData({
      fxFlag: true
    });
  },
  menuClick: function (e) {
    var _id = e.target.dataset.id;
    this.setData({
      tab_num: _id,
      _list: _id
    });
  },
  phoneBtn: function () {
    //拨打电话
    tt.makePhoneCall({
      phoneNumber: '188-6035-1905'
    });
  }
});